public class Main2 {
    public static void main(String[] args) {
        int[] arr1 = new int[]{1,3,7,8,0,0,0,0};
        int[] arr2 = new int[]{0,2,4,5};
        merge(arr1,4,arr2,4);
        for(int x:arr1) {
            System.out.print(x + " ");
        }
    }

    //升序
    public static void merge(int[] arr1,int m,int[] arr2,int n) {
        int k = arr1.length-1;
        while(m-1>=0 && n-1>=0) {
            if(arr1[m-1] >= arr2[n-1]) {
                arr1[k--] = arr1[m-1];
                m--;
            } else {
                arr1[k--] = arr2[n-1];
                n--;
            }
        }
        while(n-1 >= 0) {
            arr1[k--] = arr2[n-1];
            n--;
        }
    }
}
